package com.viators.actions;

import com.viators.beans.ListaBean;
import com.viators.model.GestionListaPasajeros;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

/**
 *
 * @author elvis
 */
public class ConsultaNroAction extends org.apache.struts.actions.DispatchAction{

    private static final Logger logger = Logger.getLogger(ConsultaNroAction.class);

      public ActionForward consultarNro(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {

          int nlipa_codigo = Integer.parseInt(request.getParameter("nlipa_codigo"));
        GestionListaPasajeros glp = new GestionListaPasajeros();
        List<ListaBean> lis = glp.obtenerListas(nlipa_codigo);
        boolean flag = false;
        if(lis!= null && lis.size()>0 ){
            flag = true;
        }else{
            flag = false;
        }
        request.getSession().setAttribute("listas", lis);
        request.setAttribute("validador", flag);
        request.setAttribute("mensaje", "");
        return mapping.findForward("validar");
    }


       public ActionForward consultarVehiculo(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
            logger.info("lista de listas por datos de vehiculo");
        String paisCarromod = request.getParameter("paisCarromod");
        String placamod = request.getParameter("placamod");
        String paisConmod = request.getParameter("paisConmod");
        String tipoIdmod = request.getParameter("tipoIdmod");
        String nromod = request.getParameter("nromod");

        GestionListaPasajeros glp = new GestionListaPasajeros();
        List<ListaBean> lis = glp.obtenerListarVh(paisCarromod,placamod,paisConmod,tipoIdmod,nromod);
        boolean flag = false;
        logger.info(" "+lis.size());
        if(lis!= null && lis.size()>0 ){
            flag = true;
        }else{
            flag = false;
        }

        request.getSession().setAttribute("listas", lis);
        request.setAttribute("validador", flag);
        request.setAttribute("mensaje", "");
       return mapping.findForward("validar");

    }

}
